<?php

class FileController extends Buzz_AuthedController {
    public function init() {
        $this->_helper->viewRenderer->setNoRender();
        $this->_helper->layout()->disableLayout();
    }

    public function doPreDispatch() {
        return;
    }

    // NOT YET SUPPOSED TO WORK.
    public function requestAction() {
        $response = $this->getResponse();
        /*$file = 'whatever.zip';
        $filename = 'whatever.zip';*/
        $bits = @file_get_contents($file);
        if(strlen($bits) == 0) {
            $response->setBody('Sorry, we could not find requested download file.');
        } else {
            $response->setHeader('Content-type', 'application/octet-stream', true);
            $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"', true);
            $response->setHeader('Content-Transfer-Encoding', 'binary', true);
            $response->setHeader('Content-Length', filesize($file));

            $response->setBody($bits);
        }
    }
}

